package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ByCcs;
import com.ruoyi.system.service.IByCcsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ByCcsController
 * 
 * @author ruoyi
 * @date 2024-07-12
 */
@RestController
@RequestMapping("/system/ccs")
public class ByCcsController extends BaseController
{
    @Autowired
    private IByCcsService byCcsService;

    /**
     * 查询ByCcs列表
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:list')")
    @GetMapping("/list")
    public TableDataInfo list(ByCcs byCcs)
    {
        startPage();
        List<ByCcs> list = byCcsService.selectByCcsList(byCcs);
        return getDataTable(list);
    }

    /**
     * 导出ByCcs列表
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:export')")
    @Log(title = "ByCcs", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ByCcs byCcs)
    {
        List<ByCcs> list = byCcsService.selectByCcsList(byCcs);
        ExcelUtil<ByCcs> util = new ExcelUtil<ByCcs>(ByCcs.class);
        util.exportExcel(response, list, "ByCcs数据");
    }

    /**
     * 获取ByCcs详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(byCcsService.selectByCcsById(id));
    }

    /**
     * 新增ByCcs
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:add')")
    @Log(title = "ByCcs", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ByCcs byCcs)
    {
        return toAjax(byCcsService.insertByCcs(byCcs));
    }

    /**
     * 修改ByCcs
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:edit')")
    @Log(title = "ByCcs", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ByCcs byCcs)
    {
        return toAjax(byCcsService.updateByCcs(byCcs));
    }

    /**
     * 删除ByCcs
     */
    @PreAuthorize("@ss.hasPermi('system:ccs:remove')")
    @Log(title = "ByCcs", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(byCcsService.deleteByCcsByIds(ids));
    }
}
